import React, { Component } from 'react'
import './tabcontrol.css'
export default class tabcontrol extends Component {
    constructor(){
        super()
        this.state = {
            current:0
        }
    }
    render() {
        const {list} = this.props
        return (
            <div className='tabbox'>
               {
                   list.map((item,index)=>{
                        return <div className={'tabboxli'+(index === this.state.current ? 'active':'')} key={index} onClick={e=>{this.itemClick(index)}}>{item}</div>
                   })
               }
            </div>
        )
    }
    itemClick(index){
        this.setState({
            current:index
        })
        const {itemClick} = this.props
        itemClick(index)
    }
}
